/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package carcassonne.gui;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.net.URL;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 *
 * @author Jeff
 */
public class MainMenuButtonPanel extends JPanel {

	private String buttonText;
	private JLabel textLabel;
	private Image backgroundImage;
	
	public MainMenuButtonPanel(String buttonText, URL backgroundUrl) {
		this.setButtonText(buttonText);
		
		this.setBackgroundImage(Toolkit.getDefaultToolkit().getImage(backgroundUrl));
		
		JLabel tempLabel = new JLabel(this.getButtonText());
		tempLabel.setForeground(new Color(252,200,40));
		this.setTextLabel(tempLabel);
		this.add(this.getTextLabel());
		
		this.setComponentZOrder(this.getTextLabel(), 0);
	}

	public void paintComponent(Graphics g) {
		super.paintComponent(g);

		//Draw image to fill panel   
		g.drawImage(this.getBackgroundImage(), 0, 0, this.getWidth(), this.getHeight(), 0, 0, this.getBackgroundImage().getWidth(this), this.getBackgroundImage().getHeight(this), this);
	}
		
	public String getButtonText() {
		return buttonText;
	}

	private void setButtonText(String buttonText) {
		this.buttonText = buttonText;
	}

	private JLabel getTextLabel() {
		return textLabel;
	}

	private void setTextLabel(JLabel textLabel) {
		this.textLabel = textLabel;
	}

	private Image getBackgroundImage() {
		return backgroundImage;
	}

	private void setBackgroundImage(Image backgroundImage) {
		this.backgroundImage = backgroundImage;
	}
}
